package cn.mengfly.fxtest.app;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class AnchorPaneApp extends Application {



    @Override
    public void start(Stage primaryStage) {

        AnchorPane ap = new AnchorPane();
        Scene scene = new Scene(ap);

        Hyperlink signoutLink = new Hyperlink("Sign Out");
        ap.getChildren().add(signoutLink);
        AnchorPane.setTopAnchor(signoutLink, 10d);
        AnchorPane.setRightAnchor(signoutLink, 10d);

        Circle circle = new Circle();
        circle.setFill(Color.GREEN);
        circle.setRadius(10);

        Label connLabel = new Label("Connection");

        HBox connBox = new HBox();
        connBox.setSpacing(4);
        connBox.setAlignment(Pos.BOTTOM_RIGHT);
        connBox.getChildren().addAll(connLabel, circle);
        AnchorPane.setBottomAnchor(connBox, 10d);
        AnchorPane.setRightAnchor(connBox, 10d);

        ap.getChildren().add(connBox);

        Label statusLabel = new Label("Program status");
        ap.getChildren().add(statusLabel);
        AnchorPane.setBottomAnchor(statusLabel, 10d);
        AnchorPane.setLeftAnchor(statusLabel, 10d);

        TextArea ta = new TextArea();
        AnchorPane.setTopAnchor(ta, 40d);
        AnchorPane.setBottomAnchor(ta, 40d);
        AnchorPane.setRightAnchor(ta, 10d);
        AnchorPane.setLeftAnchor(ta, 10d);
        ap.getChildren().add(ta);

        primaryStage.setScene(scene);
        primaryStage.setTitle("AnchorPaneApp");
        primaryStage.show();

    }
}
